package com.xiyu.service.controller.admin.bed;
import com.xiyu.service.vo.bed.bedInfo.BedInfoPageQueryOutput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoPageQueryInput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoGetByRoomIdOutput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoListQueryRoomTypeOutput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoListQueryBedTypeOutput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoSingleGetRoomTypeOutput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoSingleGetBedTypeOutput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoRoomUpdateInput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoRoomCreateInput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoBedTypeUpdateInput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoBedTypeCreateInput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoBedTypeQueryOutput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoBedTypeQueryInput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoRoomTypeUpdateInput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoRoomTypeCreateInput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoRoomTypeQueryOutput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoRoomTypeQueryInput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoGetBedOutput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoGetRoomOutput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoRoomQueryOutput;
import com.xiyu.service.vo.bed.bedInfo.BedInfoRoomQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.bed.BedInfoService;

@Tag(name = "床位信息")
@RestController
@RequestMapping("/bed/bed-info")
@Validated
public class BedInfoController {

    @Resource
    private BedInfoService bedInfoService;

    @GetMapping("/room-query")
    @Operation(summary = "分页查询房间信息")
    @PreAuthorize("@ss.hasPermission('bed:info:query')")
    public CommonResult<PageResult<BedInfoRoomQueryOutput>> roomQuery(@Valid BedInfoRoomQueryInput inputVO) {
        return success(bedInfoService.roomQuery(inputVO));
    }

    @GetMapping("/get-room")
    @Operation(summary = "查询单个房间")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<BedInfoGetRoomOutput> getRoom(@RequestParam("id") Long id) {
        return success(bedInfoService.getRoom(id));
    }

    @GetMapping("/get-bed")
    @Operation(summary = "获取单个床位")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<BedInfoGetBedOutput> getBed(@RequestParam("id") Long id) {
        return success(bedInfoService.getBed(id));
    }

    @GetMapping("/room-type-query")
    @Operation(summary = "分页查询房间类型")
    public CommonResult<PageResult<BedInfoRoomTypeQueryOutput>> roomTypeQuery(@Valid BedInfoRoomTypeQueryInput inputVO) {
        return success(bedInfoService.roomTypeQuery(inputVO));
    }

    @PostMapping("/room-type-create")
    @Operation(summary = "创建房间类型")
    public CommonResult<Long> roomTypeCreate(@Valid @RequestBody BedInfoRoomTypeCreateInput inputVO) {
        return success(bedInfoService.roomTypeCreate(inputVO));
    }

    @PutMapping("/room-type-update")
    @Operation(summary = "更新房间类型")
    public CommonResult<Boolean> roomTypeUpdate(@Valid @RequestBody BedInfoRoomTypeUpdateInput inputVO) {
        return success(bedInfoService.roomTypeUpdate(inputVO));
    }

    @DeleteMapping("/room-type-deleted")
    @Operation(summary = "删除房间类型")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<Boolean> roomTypeDeleted(@RequestParam("id") Long id) {
        return success(bedInfoService.roomTypeDeleted(id));
    }

    @GetMapping("/bed-type-query")
    @Operation(summary = "分页查询床位类型")
    public CommonResult<PageResult<BedInfoBedTypeQueryOutput>> bedTypeQuery(@Valid BedInfoBedTypeQueryInput inputVO) {
        return success(bedInfoService.bedTypeQuery(inputVO));
    }

    @PostMapping("/bed-type-create")
    @Operation(summary = "创建房间类型")
    public CommonResult<Long> bedTypeCreate(@Valid @RequestBody BedInfoBedTypeCreateInput inputVO) {
        return success(bedInfoService.bedTypeCreate(inputVO));
    }

    @PutMapping("/bed-type-update")
    @Operation(summary = "更新床位类型")
    public CommonResult<Boolean> bedTypeUpdate(@Valid @RequestBody BedInfoBedTypeUpdateInput inputVO) {
        return success(bedInfoService.bedTypeUpdate(inputVO));
    }

    @DeleteMapping("/bed-type-deleted")
    @Operation(summary = "删除床位类型")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<Boolean> bedTypeDeleted(@RequestParam("id") Long id) {
        return success(bedInfoService.bedTypeDeleted(id));
    }

    @PostMapping("/room-create")
    @Operation(summary = "创建房间")
    @PreAuthorize("@ss.hasPermission('bed:info:create-room')")
    public CommonResult<Long> roomCreate(@Valid @RequestBody BedInfoRoomCreateInput inputVO) {
        return success(bedInfoService.roomCreate(inputVO));
    }

    @PutMapping("/room-update")
    @Operation(summary = "更新房间信息")
    @PreAuthorize("@ss.hasPermission('bed:info:update-room')")
    public CommonResult<Boolean> roomUpdate(@Valid @RequestBody BedInfoRoomUpdateInput inputVO) {
        return success(bedInfoService.roomUpdate(inputVO));
    }

    @DeleteMapping("/room-deleted")
    @Operation(summary = "删除房间信息")
    @PreAuthorize("@ss.hasPermission('bed:info:deleted-room')")
    @Parameter(name = "id", description = "主键ID", example = "")
    public CommonResult<Boolean> roomDeleted(@RequestParam("id") Long id) {
        return success(bedInfoService.roomDeleted(id));
    }


    @GetMapping("/single-get-bed-type")
    @Operation(summary = "获取单个")
    @Parameter(name = "id", description = "床位类型主键ID", example = "")
    public CommonResult<BedInfoSingleGetBedTypeOutput> singleGetBedType(@RequestParam("id") Long id) {
        return success(bedInfoService.singleGetBedType(id));
    }

    @GetMapping("/single-get-room-type")
    @Operation(summary = "获取单个房间类型")
    @Parameter(name = "id", description = "房间类型主键ID", example = "")
    public CommonResult<BedInfoSingleGetRoomTypeOutput> singleGetRoomType(@RequestParam("id") Long id) {
        return success(bedInfoService.singleGetRoomType(id));
    }

    @GetMapping("/list-query-bed-type")
    @Operation(summary = "查询床位类型")
    public CommonResult<List<BedInfoListQueryBedTypeOutput>> listQueryBedType() {
        return success(bedInfoService.listQueryBedType());
    }

    @GetMapping("/list-query-room-type")
    @Operation(summary = "查询房间类型")
    public CommonResult<List<BedInfoListQueryRoomTypeOutput>> listQueryRoomType() {
        return success(bedInfoService.listQueryRoomType());
    }

    @GetMapping("/get-by-room-id")
    @Operation(summary = "根据roomID获取床位信息")
    @Parameter(name = "id", description = "房间信息主键ID", example = "")
    public CommonResult<List<BedInfoGetByRoomIdOutput>> getByRoomId(@RequestParam("id") Long id) {
        return success(bedInfoService.getByRoomId(id));
    }

    @GetMapping("/page-query")
    @Operation(summary = "分页查询")
    public CommonResult<PageResult<BedInfoPageQueryOutput>> pageQuery(@Valid BedInfoPageQueryInput inputVO) {
        return success(bedInfoService.pageQuery(inputVO));
    }

}
